package com.wn.base.algorithm;

import java.util.ArrayList;
import java.util.List;

/**
 * @FileName: ConditionField
 * @Description: 条件属性
 * @Author: MaWenHao
 * @Created: 2020/11/18 - 9:26 下午
 */
public class ConditionField<T> {

    private int cursor;

    private List<T> fields = new ArrayList<>(10);

    public int getCursor() {
        return cursor;
    }

    public boolean addField(T data) {
        return fields.add(data);
    }

    public T getLast() {
        int size = fields.size();
        if (size == 0) {
            return null;
        }
        return fields.get(size - 1);
    }

    public T getCurrent() {
        return fields.get(cursor);
    }

    public boolean next() {
        if (cursor < fields.size() - 1) {
            cursor ++;
            return true;
        }
        return false;
    }
}
